enum Type{
    //% block="包含"
    0,
    //% block="不包含"
    None

}
enum MODE{
    //% block="行"
    1,
    //% block="列"
    0
}
//% color="#CCCC99" iconWidth=50 iconHeight=40
namespace Pandas{
  
    //% block="初始化Pandas模块" blockType="command"   
    export function pandas_init(parameter: any, block: any) {
        
        Generator.addCode(`import pandas as pd`);
        
    }  

    //% block="[Variable] 读取CSV [Csv] [Mode] 标题行" blockType="command"
    //% Variable.shadow="String" Variable.defl="df"
    //% Csv.shadow="String" Csv.defl="data.CSV"
    //% Mode.shadow="dropdown"  Mode.options="Type"  Mode.defl="Type.包含"
    export function PandasReadCsv(parameter: any, block: any) {
        
        var variable = parameter.Variable.code;
        var csv = parameter.Csv.code;
        var mode = parameter.Mode.code;

        Generator.addCode(`${variable}= pd.read_csv('${csv}', header=${mode})`);
        

        
    }


     //% block="创建series[VAR]通过列表或字典[TYPE] " blockType="command"
     //% VAR.shadow="String" VAR.defl="ser" 
     //% TYPE.shadow="String" TYPE.defl="mylist"
    export function pdSer(parameter: any, block: any) {
        var Var = parameter.VAR.code;
        var Type = parameter.TYPE.code;
    
        Generator.addCode(`${Var} = pd.Series(${Type})`);
        
    }
     //% block="创建series[VAR]通过列表或字典[TYPE] 索引为[List] " blockType="command"
     //% VAR.shadow="String" VAR.defl="ser" 
     //% TYPE.shadow="String" TYPE.defl="mylist"
     //% List.shadow="list" List.defl="0,1,2,3"
     export function pdSer1(parameter: any, block: any) {
        var Var = parameter.VAR.code;
        var Type = parameter.TYPE.code;
        var list = parameter.List.code;
        Generator.addCode(`${Var} = pd.Series(${Type},index=${list})`);
        
    }

     //% block="创建二维数据表[VAR]通过列表或字典[TYPE] " blockType="command"
     //% VAR.shadow="String" VAR.defl="df" 
     //% TYPE.shadow="String" TYPE.defl="mylist"
     export function pddf(parameter: any, block: any) {
        var Var = parameter.VAR.code;
        var Type = parameter.TYPE.code;
    
        Generator.addCode(`${Var} = pd.DataFrame(${Type})`);
        
    }
     //% block="创建二维数据[VAR]通过列表或字典[TYPE] 索引为[List] " blockType="command"
     //% VAR.shadow="String" VAR.defl="df" 
     //% TYPE.shadow="String" TYPE.defl="mylist"
     //% List.shadow="list" List.defl="'a','b','c','d'"
     export function pddf1(parameter: any, block: any) {
        var Var = parameter.VAR.code;
        var Type = parameter.TYPE.code;
        var list = parameter.List.code;
        Generator.addCode(`${Var} = pd.DataFrame(${Type},index=${list})`);
        
    }
     //% block="创建二维数据[VAR]通过列表或字典[TYPE] 列索引[Col]行索引为[List] " blockType="command"
     //% VAR.shadow="String" VAR.defl="df" 
     //% TYPE.shadow="String" TYPE.defl="mylist"
     //% Col.shadow="list" Col.defl="ABCD"
     //% List.shadow="list" List.defl="'a','b','c','d'"
     export function pddf2(parameter: any, block: any) {
        var Var = parameter.VAR.code;
        var Type = parameter.TYPE.code;
        var list = parameter.List.code;
        var col = parameter.Col.code;
        Generator.addCode(`${Var} = pd.DataFrame(${Type},columns=${col},index=${list})`);
        
    }

    //% block=" [Ser] 的第[NUM] 项" blockType="reporter"
    //% Ser.shadow="String" Ser.defl="ser"
    //% NUM.shadow="String" NUM.defl="0"
    export function pdOp(parameter: any, block: any) {
        var ser = parameter.Ser.code;
        var num = parameter.NUM.code;
        Generator.addCode(`${ser}[${num}]`);
        
    }
    //% block=" [Df] 获取标签[Tag]对应的[Mode]" blockType="reporter"
    //% Df.shadow="String" Df.defl="df"
    //% Tag.shadow="String" Tag.defl="tag"
    //% Mode.shadow="dropdown" Mode.options="MODE" Mode.defl="MODE.行"
    export function pdOp1(parameter: any, block: any) {
        var df = parameter.Df.code;
        var tag = parameter.Tag.code;
        var mode = parameter.Mode.code;
        if (mode == 1){
            Generator.addCode(`${df}.loc['${tag}']`);
        }else{
            Generator.addCode(`${df}['${tag}']`);
        }
       
        
    }
    //% block="---"
    export function noteSep1() {

    }

    


    
}
